import js from '@eslint/js'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import pluginVue from 'eslint-plugin-vue'
import { defineConfig, globalIgnores } from 'eslint/config'
import globals from 'globals'

export default defineConfig([
  {
    name: 'app/files-to-lint',
    files: ['**/*.{js,mjs,jsx,vue}'],
  },

  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  {
    languageOptions: {
      globals: {
        ...globals.browser,
      },
    },
  },

  js.configs.recommended,
  ...pluginVue.configs['flat/essential'],
  skipFormatting,
  {
    // 新增的规则配置，放在最后生效
    rules: {
      'vue/multi-word-component-names': 'off',
      'padding-line-between-statements': [
        'error',
        // import 之后必须有一行空行（如果后面不是 import）
        { blankLine: 'always', prev: 'import', next: '*' },
        // import 和 import 之间禁止空行
        { blankLine: 'never', prev: 'import', next: 'import' },
      ],
    },
  },
])
